package com.chenfan.mcn.component.dict;

import com.chenfan.common.extension.context.SpringContextHolder;
import com.chenfan.mcn.constant.SeparatorCst;
import com.chenfan.mcn.dao.StarPlatformInfoMapper;
import com.chenfan.common.extension.dict.DictTranslator;
import com.chenfan.mcn.model.StarPlatformInfo;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author: WQ
 * Date 2022/11/4
 * @描述
 */
public class StarPlatformInfoIdTranslator implements DictTranslator<Long, String> {
    @Override
    public String translate(Long id) {
        StarPlatformInfoMapper platformInfoMapper = SpringContextHolder.getBean(StarPlatformInfoMapper.class);
        StarPlatformInfo starPlatformInfo = platformInfoMapper.selectById(id);
        return Objects.nonNull(starPlatformInfo) ? StringUtils.joinWith(SeparatorCst.OBLIQUE_LINE, starPlatformInfo.getPlatNickName(), starPlatformInfo.getPlatformName()) : id.toString();
    }
}
